home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / m68k / 139 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  60 lines

  1. Newsgroups: comp.sys.m68k
  2. Path: netcom.com!ludis
  3. From: ludis@netcom.com (Ludis Langens)
  4. Subject: Re: how to convert locical to physical address on 68040
  5. Message-ID: <ludisDLMsKv.344@netcom.com>
  6. Organization: It's here somewhere
  7. References: <Pine.SOL.3.91.960122210823.17385A-100000@emmi.physik.TU-Berlin.DE>
  8. Date: Tue, 23 Jan 1996 11:14:55 GMT
  9. Sender: ludis@netcom9.netcom.com
  10.  
  11. In article <Pine.SOL.3.91.960122210823.17385A-100000@emmi.physik.TU-Berlin.DE> Peter Kelm <kelm@emmi.physik.TU-Berlin.DE> writes:
  12. >Hello,
  13. >I need to convert a given logical address into a physical one (I am 
  14. >programming on a macintosh but the code of course is only processor 
  15. >dependent). The problem behind is to examine how the MacOS has mapped 
  16. >itself (to get NetBSD un*x running on a 040). Read all of the literature I 
  17. >could get (for example M68040 Users Manual). But my code still fails. 
  18. >
  19. >This is what I tried:
  20. >1) use "ptestr (a0)" wit the logical address in a0. The get the mmusr 
  21. >(movec mmusr,d0), extract the address part and put it together with a 
  22. >part of the logical address to form the physical.
  23. >2) -get mmu root pointer
  24. >   -do the table walk by hand (get TIA part - form root level table 
  25. >descriptor, get TIB part, ...)
  26. >
  27. >The processor is in supervisor mode.
  28. >Has anyone out there a working address conversion code or a URL pointer 
  29. >to such a source code fragment ???
  30.  
  31. Either method you tried probably should work.  However, for method 2,
  32. all the mmu pointers are physical addresses.  Because you don't know
  33. the LtoP (or PtoL) translation, you can't read the mmu tables!  There
  34. are various tricks (such as alternative function code spaces) to get
  35. around this problem.  Because all these tricks depend on the OS and/or
  36. system hardware configuration, this is not a portable solution.
  37.  
  38. Are you really in supervisor mode?  Mac VM fakes supervisor mode (by
  39. emulating certain priviledged instructions).
  40.  
  41. The MacOS provides a function that gives you the physical addresses
  42. for a range of logical addresses.  (This is meant for use with DMA
  43. devices and so on.)
  44.  
  45. The memory location DDC (I think) points at a data structure that decribes
  46. the memory layout.  (The structure is mostly at negative offsets from
  47. the pointer.  The MMU tables are also located in this memory range.)
  48. When Apple's VM loads, it will use the data here to create its own (new)
  49. mmu tables.
  50.  
  51. To help you read the non-VM mmu tables, location 1EF8 (I think) contains
  52. the PtoL address offset for the mmu table itself.  (Add the value to
  53. the physical address to get the logical...)  This only works if the
  54. tables are contiguous... (which they are).
  55.  
  56. -- 
  57.                    unsigned long BinToBCD(unsigned long i) {unsigned long t;
  58. Ludis Langens         return i ? (t = BinToBCD(i >> 1), (t << 1) + (i & 1) + 
  59. ludis@netcom.com                 (t + 858993459 >> 2 & 572662306) * 3) : 0;}
  60.